package com.hu.flink12.sensor

import com.hu.entity.SensorReading
import org.apache.flink.api.common.RuntimeExecutionMode
import org.apache.flink.streaming.api.scala._

/**
 * @Author: hujianjun
 * @Create Date: 2021/1/26 16:01
 * @Describe: 从集合读取数据
 */

object ReadSensorCollect {
  def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.getExecutionEnvironment

    val inputStream = env.fromCollection(List(
      SensorReading("sensor_1", 1547718199, 35.8),
      SensorReading("sensor_6", 1547718201, 15.4),
      SensorReading("sensor_7", 1547718202, 6.7),
      SensorReading("sensor_10", 1547718205, 38.1)
    ))

    inputStream.print().setParallelism(1)

    env.setRuntimeMode(RuntimeExecutionMode.BATCH)
    env.execute("读取传感器集合数据")
  }
}
